package com.pro.controller;

import com.pro.pojo.JsUserDevelopment;
import com.pro.pojo.JsonData;
import com.pro.service.JsUserDevelopmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * ClassName:JsUserDevelopmentController
 * Package:com.pro.controller
 * Description:
 *
 * @Date:2021/11/14 15:02
 * @Author: ZPT
 */
@RequestMapping("/jinsi")
@RestController
public class JsUserDevelopmentController {
    @Autowired
    private JsUserDevelopmentService service;

    @RequestMapping("/getUserDevelopmentTable")
    public JsonData getUserDevelopmentTable(Integer userCode,Integer studyDate,Integer consumption){
        return service.getUserDevelopmentTable(userCode,studyDate,consumption);
    }

    @RequestMapping("/updateType")
    public JsonData updateType(Integer userId,Integer type){
        Integer i = service.updateType(userId, type);
        return i>0?JsonData.buildSuccess(i):JsonData.buildError("服务端错误");
    }

    @RequestMapping("/getSearchUserDevelopment")
    public JsonData getSearchUserDevelopment(String nickname, String profession){
        nickname = nickname!=null?"%"+nickname+"%":"%%";
        profession = profession!=null?"%"+profession+"%":"%%";
        List<JsUserDevelopment> list = service.getSearchUserDevelopment(nickname,profession);
        return list!=null?JsonData.buildSuccess(list):JsonData.buildError("服务端错误");
    }

    @RequestMapping("/getinformation")
    public JsonData getinformation(Integer userId){
        JsUserDevelopment jsUserDevelopment = service.getinformation(userId);
        return jsUserDevelopment!=null?JsonData.buildSuccess(jsUserDevelopment):JsonData.buildError("服务端错误");
    }

    @RequestMapping("/updateUserDevelop")
    public JsonData updateUserDevelop(JsUserDevelopment jsUserDevelopment){
        Boolean aBoolean = service.updateUserDevelop(jsUserDevelopment);
        return aBoolean!=null?JsonData.buildSuccess(aBoolean):JsonData.buildError("服务端错误");
    }

    @RequestMapping("/addUserDevelop")
    public JsonData addUserDevelop(JsUserDevelopment jsUserDevelopment){
        Boolean aBoolean = service.addUserDevelop(jsUserDevelopment);
        return aBoolean!=null?JsonData.buildSuccess(aBoolean):JsonData.buildError("服务端错误");
    }
}
